package com.gd.iot.energy.controller.systemadmin;

import com.gd.iot.energy.annotation.SystemLogRecordMonitor;
import com.gd.iot.energy.entity.ResponseEntity;
import com.gd.iot.energy.pojo.common.vo.PageVO;
import com.gd.iot.energy.pojo.systemadmin.dto.ArchivesChangeSaveDTO;
import com.gd.iot.energy.pojo.systemadmin.vo.ArchivesChangePageVO;
import com.gd.iot.energy.service.systemadmin.ArchivesChangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 系统管理-系统设置-拆换表管理
 *
 * @author kris
 * @date Created at 2020/8/3 10:50
 */
@RestController
@RequestMapping("/admin/logArchivesChange")
@Api(value = "系统管理-系统设置-拆换表管理",tags = "系统管理-系统设置-拆换表管理")
public class LogArchivesChangeController {
    @Autowired
    private ArchivesChangeService archivesChangeService;

    @ApiOperation("获取拆换表分页列表")
    @SystemLogRecordMonitor("获取拆换表分页列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "areaOrg", value = "区域ID", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "customerName", value = "客户名称", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "customerSerialnumber", value = "客户编号", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "serialnumber", value = "表计地址", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "orderColumn", value = "排序字段", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "orderType", value = "排序类型", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/getPageList")
    public ResponseEntity<PageVO<ArchivesChangePageVO>> getPageList(
            @RequestParam(value = "areaOrg",required = false)Long areaOrg,
            @RequestParam(value = "customerName",required = false)String customerName,
            @RequestParam(value = "customerSerialnumber",required = false)String customerSerialnumber,
            @RequestParam(value = "serialnumber",required = false)String serialnumber,
            @RequestParam(value = "pageSize",required = false,defaultValue = "10")Integer pageSize,
            @RequestParam(value = "pageNum",required = false,defaultValue = "1")Integer pageNum,
            @RequestParam(value = "orderColumn",required = false,defaultValue = "id") String orderColumn,
            @RequestParam(value = "orderType",required = false,defaultValue = "asc") String orderType
    ) {

        PageVO<ArchivesChangePageVO> pageVO = archivesChangeService.getArchivesChangePageVOs(areaOrg,customerName,customerSerialnumber,serialnumber,pageSize,pageNum,orderColumn,orderType);
        return new ResponseEntity<>(pageVO);
    }

    @ApiOperation("获取拆换表")
    @SystemLogRecordMonitor("获取拆换表")
    @PostMapping("/get")
    public ResponseEntity<ArchivesChangeSaveDTO> get(Integer id){
        ArchivesChangeSaveDTO roleVO = archivesChangeService.getArchivesChange(id);
        return new ResponseEntity<>(roleVO);
    }

    @ApiOperation("拆表")
    @SystemLogRecordMonitor("拆表")
    @PostMapping("/remove")
    public ResponseEntity<Boolean> remove(@RequestBody ArchivesChangeSaveDTO archivesChangeSaveDTO){
        boolean res = archivesChangeService.remove(archivesChangeSaveDTO);
        return new ResponseEntity<>(res);
    }

    @ApiOperation("换表")
    @SystemLogRecordMonitor("换表")
    @PostMapping("/change")
    public ResponseEntity<Boolean> change(@RequestBody ArchivesChangeSaveDTO archivesChangeSaveDTO){
        boolean res = archivesChangeService.change(archivesChangeSaveDTO);
        return new ResponseEntity<>(res);
    }
}
